package cn.codingstyle.promotion;

import cn.codingstyle.product.*;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class PromotionRepositoryImpl implements PromotionRepository {
    private final PromotionDAO promotionDAO;

    public PromotionRepositoryImpl(PromotionDAO promotionDAO) {
        this.promotionDAO = promotionDAO;
    }

    @Override
    public Promotion findById(Integer id) {
        return promotionDAO.findById(id).map(PromotionDO::toEntity).get();
    }
}
